
import 'package:event_listener/bean/EventNotifyBean.dart';
import 'package:event_listener/enums/EventNotify.dart';

import 'event_listener_platform_interface.dart';

class EventListener {

  /// Constructs a singleton instance of [TelinkOta].
  ///
  /// [TelinkOta] is designed to work as a singleton.
  // When a second instance is created, the first instance will not be able to listen to the
  // EventChannel because it is overridden. Forcing the class to be a singleton class can prevent
  // misuse of creating a second instance from a programmer.
  factory EventListener() {
    _singleton ??= EventListener._();
    return _singleton!;
  }

  EventListener._();

  static EventListener? _singleton;

  static EventListenerPlatform get _platform{
    return EventListenerPlatform.instance;
  }

  Future<String?> getPlatformVersion() {
    return _platform.getPlatformVersion();
  }

  Future<void> startListening() async{
    await _platform.startListening();
  }

  /// Fires whenever the EventNotify changes.
  Stream<EventNotifyBean> get onEventNotifyChanged {
    return _platform.onEventNotifyChanged;
  }

}
